<template>
	<Layout :pagebg="2" class-name="scan">
    <!-- <view class="title" :class="'title'+params.type_id">{{detail.title}}</view> -->
    <view class="images" v-if="params.type_id == 1">
      <uv-parse :content="content"></uv-parse>
      <!-- <ux-parse :content="content" @navigate="linkOther"></ux-parse> -->
    </view>
    <video v-else-if="params.type_id == 2" :src="detail.video_desc" class="video-box"></video>
    <view v-else-if="params.type_id == 3" class="content">
      <uv-parse :content="detail.content"></uv-parse>
      <!-- <ux-parse :content="detail.content" @navigate="linkOther"></ux-parse> -->
    </view>
  </Layout>
</template>

<script>
	export default {
		data() {
			return {
				detail:null,
        params:null,
        content:''
			}
		},
    onLoad(e){
      console.log('------------------------------------------------------', e,decodeURIComponent(e.scene).split('@'))
      const _scene = decodeURIComponent(e.scene).split('@')
      this.params = {type_id: _scene[0], id: _scene[1]}
       // this.params = e;
      // this.params = {type_id: 1, id: 8}; // 1- 图
      // this.params = {type_id: 2, id: 7}; // 2- 视频
      // this.params = {type_id: 3, id: 6}; // 3- 图文
      console.log('this.params------------------------------------------------------', this.params)

      this.getCon()
      
    },
    watch:{
      loading(n,o){
        if(this.loading > 1){
          uni.hideLoading()
        }else{
          uni.showLoading()
        }
      }
    },
		methods: {
      linkOther(e){
        getApp().linkToOther(e)
      },
      getCon(){
        this.$api.getScanInfoApi(this.params).then(res=>{
          this.detail = res.data;
          if(this.params.type_id == 1 && res.data && res.data.images_desc && res.data.images_desc.length > 0){
            res.data.images_desc.forEach(m =>{
              this.content+=`<img src="${m}" alt="" />`
            })
            
          }
        })
      },
      // 获取扫码获取的参数
      parseQueryParams(queryStr) {
        const params = {};
        if (!queryStr || typeof queryStr !== 'string') {
          return params; // 空字符串或非字符串直接返回空对象
        }
      
        // 分割参数对（如 ["type_id=2", "id=7"]）
        const paramPairs = queryStr.split('&');
        
        paramPairs.forEach(pair => {
          // 分割键和值（如 "type_id=2" → ["type_id", "2"]）
          const [key, value] = pair.split('=');
          if (key) {
            // 处理值可能为undefined的情况（如参数为"type_id="时）
            params[key] = value !== undefined ? decodeURIComponent(value) : '';
          }
        });
      
        return params;
      }
		},
    onPageScroll(e) {
      getApp().setNavFixed(this,e)
    },
    onReachBottom() {
    	if(!this.traveData.isLast){
        this.getList1()
      }
      if(!this.matchData.isLast){
        this.getList2()
      }
      if(!this.shop.isLast){
        this.getList3()
      }
    }
	}
</script>
<style>
page{background-color: #fff;}
</style>
<style lang="scss" scoped>
.title{font-size: 36rpx; display: flex; align-items: flex-start; padding: 20rpx 0; justify-content: center; box-sizing: border-box;}
.title2{height: 200rpx;}
.images{padding: 0 30rpx;}
.video-box{width: 100%; height: 100vh; object-fit: contain}
.content{padding: 0 30rpx;}
</style>
